home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / api_shar / share.doc < prev    next >
Text File  |  1989-01-26  |  3KB  |  71 lines

  1.  
  2.                  Shared Memory/Data Example Programs
  3.  
  4.   The sample programs SHAREA and SHAREB demonstrate how to share memory
  5.   among multiple processes.  What's being shared is data, not code.  To
  6.   better understand shared memory, read pages 16-1 thru 16-3 of Chapter 16:
  7.   Memory Management in the DESQview API Reference Manual.  To read about
  8.   sharing program code, see the "Shared Programs" section beginning on
  9.   page 16-4.
  10.  
  11.   Shared data can be of any type or structure.  SHAREA and SHAREB
  12.   demonstrate how programs can share integer, string or structured data.
  13.   As distributed, these programs are set up to share string data.  To sample
  14.   the sharing of integer data, comment out the string-related code, then
  15.   uncomment the integer-related code.  For record/struct data, uncomment the
  16.   record/struct-related code.
  17.  
  18.   The following table specifies the commenting conventions used:
  19.  
  20.     Data Type        C Source            Pascal Source
  21.     -------------    ----------------    ----------------
  22.     integer          /*i* code *i*/      (*i* code *i*)
  23.     string           /*s* code *s*/      (*s* code *s*)
  24.     record/struct    /*r* code *r*/      (*r* code *r*)
  25.  
  26.   The following files are contained within the APISHARE.ARC file:
  27.  
  28.     SHARE.DOC     This document
  29.     SHAREA.C      C source code to be compiled/linked into SHAREA.EXE
  30.     SHAREB.C      C source code to be compiled/linked into SHAREB.EXE
  31.     SHAREA.PAS    Pascal source code to be compiled/linked into SHAREA.EXE
  32.     SHAREB.PAS    Pascal source code to be compiled/linked into SHAREB.EXE
  33.     SA-PIF.DVP    PIF file to be installed on the Open Window menu
  34.     SHAREB.DVP    PIF file called by SHAREA.EXE that loads SHAREB.EXE
  35.  
  36.   Normally, a process allocates "system memory" from within its
  37.   "process memory" pool.  Such system memory is not shareable among other
  38.   processes.  If your goal is to share a global block of data among
  39.   multiple processes, an alternate method of allocating system memory
  40.   is needed.
  41.  
  42.   Placing a single asterisk (*) in the PIF file's "Shared Memory Pathname"
  43.   field enables such an allocation scheme.  Thereafter, the process' request
  44.   for system memory will be allocated as "shared memory", taken from the
  45.   lower end of available conventional memory.  Such shared/system memory
  46.   is always accessible by all processes.  And, if your application makes
  47.   a call to api_getmem, system memory will be allocated from the shared
  48.   memory pool, instead of the normal process memory pool.
  49.  
  50.   Api_getmem also returns a pointer to where the allocated memory/data
  51.   resides.  All other processes requiring access to the shared memory need
  52.   only be told where the memory begins (i.e., a pointer to it).  In the
  53.   example programs, SHAREA (the process that makes the call to allocate
  54.   shared memory) mails this information to SHAREB (the process that needs
  55.   to be informed where the shared memory resides).
  56.  
  57.   Note that only one application needs to put the asterisk (*) in its PIF;
  58.   the one that makes the call to api_getmem.  No other application is
  59.   required to use the asterisk (*); no other process is required to make
  60.   another call to api_getmem.
  61.  
  62.   For further information contact:
  63.  
  64.     Quarterdeck Office Systems
  65.     150 Pico Boulevard
  66.     Santa Monica, CA 90405
  67.  
  68.     Voice:  (213) 392-9851 or (213) 392-9701
  69.     BBS:    (213) 396-3904 or (213) 392-2278
  70.     Fax:    (213) 399-3802
  71.